"""控制信息"""


class StudentManagerController:
    __stu_id = 100

    def __init__(self):
        self.__stu_list = []

    @property
    def stu_list(self):
        """获取列表
        """
        return self.__stu_list

    def add_student(self, student):
        """添加学生
        """
        StudentManagerController.__stu_id += 1
        student.id = StudentManagerController.__stu_id
        self.__stu_list.append(student)

    def re_student(self, student):
        """
        删除学生
        """
        for i in self.__stu_list:
            if i.id == student:
                self.__stu_list.remove(i)
                return True
        return False

    def update_student(self, value):
        """修改学生信息
        """
        for i in self.__stu_list:
            if i.id == value.id:
                i.name = value.name
                i.age = value.age
                i.score = value.score
                i.sex = value.sex
                print("修改完成！")

    def stuIDsort(self):
        """
        排序
        """
        for i in range(len(self.__stu_list) - 1):
            for j in range(i + 1, len(self.__stu_list)):
                if self.__stu_list[i].score > self.__stu_list[j].score:
                    self.__stu_list[i], self.__stu_list[j] = self.__stu_list[j], self.__stu_list[i]
